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

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

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

f = A("f")
g = B("g")
d = C("d")
h = C("h")

f.v = d
f.t = g
g.y = d
g.r = h
g.p = f
d.u = h
h.u = d
assert h.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.t: B = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
d = C("d")
h = C("h")

f.v = d
f.t = g
g.y = d
g.r = h
g.p = f
d.u = h
h.u = d
assert h.u.u.u.u.txt == "h"