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

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

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

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

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

f = A("f")
m = B("m")
c = C("c")
k = D("k")
d = E("d")

f.v = m
m.s = k
m.r = k
c.q = k
c.p = f
k.u = c
d.z = c
d.t = c
assert k.u.q.u.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

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

f = A("f")
m = B("m")
c = C("c")
k = D("k")
d = E("d")

f.v = m
m.s = k
m.r = k
c.q = k
c.p = f
k.u = c
d.z = c
d.t = c
assert k.u.q.u.p.v.txt == "m"