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

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: C = None
        self.v: A = None
        self.x: B = None
        self.txt = txt

d = A("d")
k = B("k")
j = C("j")
c = D("c")
a = A("a")

d.y = a
k.y = a
k.t = c
j.p = a
c.o = j
c.s = j
c.v = a
c.x = k
a.y = d
assert k.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: C = None
        self.v: A = None
        self.x: B = None
        self.txt = txt

d = A("d")
k = B("k")
j = C("j")
c = D("c")
a = A("a")

d.y = a
k.y = a
k.t = c
j.p = a
c.o = j
c.s = j
c.v = a
c.x = k
a.y = d
assert k.y.y.y.y.y.txt == "a"