class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: D = None
        self.x: D = None
        self.r: D = None
        self.txt = txt

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

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

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

f = A("f")
e = B("e")
g = C("g")
m = D("m")
c = D("c")
n = B("n")
b = C("b")
h = D("h")
l = A("l")

f.w = e
f.z = c
f.x = m
f.r = h
e.t = l
g.o = b
g.q = b
g.u = h
m.p = c
c.p = m
n.t = l
b.o = g
b.q = g
b.u = c
h.p = c
l.w = n
l.z = c
l.x = c
l.r = c
assert l.z.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: D = None
        self.x: D = None
        self.r: D = None
        self.txt = txt

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

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

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

f = A("f")
e = B("e")
g = C("g")
m = D("m")
c = D("c")
n = B("n")
b = C("b")
h = D("h")
l = A("l")

f.w = e
f.z = c
f.x = m
f.r = h
e.t = l
g.o = b
g.q = b
g.u = h
m.p = c
c.p = m
n.t = l
b.o = g
b.q = g
b.u = c
h.p = c
l.w = n
l.z = c
l.x = c
l.r = c
assert l.z.p.p.p.txt == "m"