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

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

i = A("i")
c = B("c")
n = B("n")
l = A("l")
m = A("m")
a = A("a")
g = A("g")
f = B("f")

i.t = c
c.t = i
n.t = g
l.t = n
m.t = c
a.t = f
g.t = f
f.t = a
assert m.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

i = A("i")
c = B("c")
n = B("n")
l = A("l")
m = A("m")
a = A("a")
g = A("g")
f = B("f")

i.t = c
c.t = i
n.t = g
l.t = n
m.t = c
a.t = f
g.t = f
f.t = a
assert m.t.t.t.txt == "c"