class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: A = None
        self.z: C = None
        self.txt = txt

i = A("i")
g = B("g")
d = C("d")
f = D("f")
m = B("m")
n = B("n")

i.u = d
g.o = f
d.w = i
d.q = f
d.v = n
f.w = d
f.z = d
f.u = i
m.o = f
n.o = f
assert f.u.u.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: A = None
        self.z: C = None
        self.txt = txt

i = A("i")
g = B("g")
d = C("d")
f = D("f")
m = B("m")
n = B("n")

i.u = d
g.o = f
d.w = i
d.q = f
d.v = n
f.w = d
f.z = d
f.u = i
m.o = f
n.o = f
assert f.u.u.w.u.txt == "d"