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

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

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

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

j = A("j")
m = B("m")
e = C("e")
c = D("c")
f = C("f")
b = B("b")
h = D("h")

j.q = b
j.t = b
j.u = b
j.o = f
m.o = f
m.p = b
e.y = b
e.t = b
e.p = j
e.z = c
c.w = e
f.y = m
f.p = j
f.z = c
f.t = b
b.o = f
b.p = m
h.w = e
assert b.p.o.y.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: C = None
        self.t: B = None
        self.u: B = None
        self.txt = txt

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

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

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

j = A("j")
m = B("m")
e = C("e")
c = D("c")
f = C("f")
b = B("b")
h = D("h")

j.q = b
j.t = b
j.u = b
j.o = f
m.o = f
m.p = b
e.y = b
e.t = b
e.p = j
e.z = c
c.w = e
f.y = m
f.p = j
f.z = c
f.t = b
b.o = f
b.p = m
h.w = e
assert b.p.o.y.o.z.txt == "c"