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

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

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

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

i = A("i")
e = B("e")
k = C("k")
a = D("a")
g = D("g")

i.y = e
e.y = k
k.t = i
k.y = g
k.q = a
a.v = i
g.v = i
assert i.y.y.t.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

i = A("i")
e = B("e")
k = C("k")
a = D("a")
g = D("g")

i.y = e
e.y = k
k.t = i
k.y = g
k.q = a
a.v = i
g.v = i
assert i.y.y.t.y.y.txt == "k"