class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

m = A("m")
f = B("f")
g = C("g")
b = D("b")

m.u = f
m.v = b
f.y = m
f.o = m
g.x = b
b.o = f
assert f.o.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

m = A("m")
f = B("f")
g = C("g")
b = D("b")

m.u = f
m.v = b
f.y = m
f.o = m
g.x = b
b.o = f
assert f.o.u.y.txt == "m"