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

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

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

d = A("d")
i = B("i")
g = C("g")
k = B("k")

d.t = i
i.u = d
i.y = g
i.x = g
g.u = i
k.u = d
k.y = g
k.x = g
assert k.y.u.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

d = A("d")
i = B("i")
g = C("g")
k = B("k")

d.t = i
i.u = d
i.y = g
i.x = g
g.u = i
k.u = d
k.y = g
k.x = g
assert k.y.u.u.t.txt == "i"