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

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

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

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

c = A("c")
k = B("k")
a = C("a")
l = D("l")
e = A("e")
f = B("f")
m = B("m")
j = B("j")
n = D("n")

c.r = k
k.o = n
k.w = n
a.r = e
a.u = c
l.z = n
e.r = m
f.o = l
f.w = n
m.o = l
m.w = n
j.o = n
j.w = n
n.z = l
assert a.r.r.o.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

c = A("c")
k = B("k")
a = C("a")
l = D("l")
e = A("e")
f = B("f")
m = B("m")
j = B("j")
n = D("n")

c.r = k
k.o = n
k.w = n
a.r = e
a.u = c
l.z = n
e.r = m
f.o = l
f.w = n
m.o = l
m.w = n
j.o = n
j.w = n
n.z = l
assert a.r.r.o.z.z.txt == "l"