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

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

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

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

f = A("f")
n = B("n")
e = C("e")
i = D("i")
j = C("j")
b = A("b")
d = B("d")
h = A("h")
m = C("m")

f.t = i
f.u = i
n.o = i
n.y = f
n.x = e
n.z = b
e.r = m
i.w = f
i.q = j
j.r = e
b.t = i
b.u = i
d.o = i
d.y = h
d.z = h
d.x = m
h.t = i
h.u = i
m.r = e
assert f.t.w.t.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.u: D = None
        self.txt = txt

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

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

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

f = A("f")
n = B("n")
e = C("e")
i = D("i")
j = C("j")
b = A("b")
d = B("d")
h = A("h")
m = C("m")

f.t = i
f.u = i
n.o = i
n.y = f
n.x = e
n.z = b
e.r = m
i.w = f
i.q = j
j.r = e
b.t = i
b.u = i
d.o = i
d.y = h
d.z = h
d.x = m
h.t = i
h.u = i
m.r = e
assert f.t.w.t.w.u.txt == "i"