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

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

i = A("i")
k = B("k")
d = C("d")
l = D("l")
f = A("f")
c = B("c")

i.p = f
k.y = c
d.v = l
l.q = c
f.p = i
c.y = k
assert f.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

i = A("i")
k = B("k")
d = C("d")
l = D("l")
f = A("f")
c = B("c")

i.p = f
k.y = c
d.v = l
l.q = c
f.p = i
c.y = k
assert f.p.p.p.txt == "i"