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.txt = txt

i = A("i")
c = B("c")
f = B("f")
n = A("n")
d = B("d")

i.t = c
c.u = n
f.u = n
n.t = d
d.u = i
assert c.u.t.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.txt = txt

i = A("i")
c = B("c")
f = B("f")
n = A("n")
d = B("d")

i.t = c
c.u = n
f.u = n
n.t = d
d.u = i
assert c.u.t.u.t.txt == "c"