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

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.p: E = None
        self.s: F = None
        self.y: F = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: E = None
        self.o: A = None
        self.txt = txt

k = A("k")
l = B("l")
h = C("h")
c = D("c")
j = E("j")
a = F("a")
b = C("b")

k.u = j
l.r = c
l.p = j
l.s = a
l.y = a
h.p = b
h.z = j
c.x = l
j.z = l
j.p = a
j.w = a
j.y = k
a.s = j
a.o = k
b.p = h
b.z = j
assert b.p.p.p.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.p: E = None
        self.s: F = None
        self.y: F = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: E = None
        self.o: A = None
        self.txt = txt

k = A("k")
l = B("l")
h = C("h")
c = D("c")
j = E("j")
a = F("a")
b = C("b")

k.u = j
l.r = c
l.p = j
l.s = a
l.y = a
h.p = b
h.z = j
c.x = l
j.z = l
j.p = a
j.w = a
j.y = k
a.s = j
a.o = k
b.p = h
b.z = j
assert b.p.p.p.p.z.txt == "j"