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

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

class C:
    def __init__(self, txt: str):
        self.u: F = None
        self.t: A = None
        self.z: B = None
        self.x: D = None
        self.txt = txt

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

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

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

f = A("f")
m = B("m")
c = C("c")
a = D("a")
k = E("k")
e = F("e")

f.p = e
f.v = k
m.z = k
c.u = e
c.t = f
c.z = m
c.x = a
a.y = c
a.w = c
a.r = f
k.y = f
k.t = m
e.p = f
e.q = k
assert a.y.u.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.v: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: F = None
        self.t: A = None
        self.z: B = None
        self.x: D = None
        self.txt = txt

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

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

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

f = A("f")
m = B("m")
c = C("c")
a = D("a")
k = E("k")
e = F("e")

f.p = e
f.v = k
m.z = k
c.u = e
c.t = f
c.z = m
c.x = a
a.y = c
a.w = c
a.r = f
k.y = f
k.t = m
e.p = f
e.q = k
assert a.y.u.p.p.p.txt == "f"