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

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

f = A("f")
c = B("c")
e = B("e")
j = A("j")
i = A("i")
m = A("m")

f.y = c
c.p = i
e.p = m
j.y = c
i.y = e
m.y = c
assert c.p.y.p.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

f = A("f")
c = B("c")
e = B("e")
j = A("j")
i = A("i")
m = A("m")

f.y = c
c.p = i
e.p = m
j.y = c
i.y = e
m.y = c
assert c.p.y.p.y.p.txt == "i"