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

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

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

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

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

f = A("f")
d = B("d")
k = C("k")
c = D("c")
l = E("l")
j = C("j")
a = A("a")

f.r = l
f.w = l
f.z = d
d.o = j
k.t = f
c.p = d
c.w = l
l.p = d
j.t = f
a.r = l
a.w = l
a.z = d
assert f.z.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.w: E = None
        self.z: B = None
        self.txt = txt

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

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

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

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

f = A("f")
d = B("d")
k = C("k")
c = D("c")
l = E("l")
j = C("j")
a = A("a")

f.r = l
f.w = l
f.z = d
d.o = j
k.t = f
c.p = d
c.w = l
l.p = d
j.t = f
a.r = l
a.w = l
a.z = d
assert f.z.o.t.txt == "f"