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

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

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

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

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

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

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