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

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

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

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

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

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

l.p = g
g.u = l
f.p = c
n.p = c
c.u = l
j.u = i
a.p = c
e.p = g
i.p = c
assert g.u.p.u.p.u.p.u.p.txt == "g"