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

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

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

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

g = A("g")
e = B("e")
b = C("b")
j = D("j")
l = A("l")
i = A("i")

g.y = b
e.r = l
e.o = i
b.q = l
j.t = e
l.y = b
i.y = b
assert i.y.q.y.q.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

g = A("g")
e = B("e")
b = C("b")
j = D("j")
l = A("l")
i = A("i")

g.y = b
e.r = l
e.o = i
b.q = l
j.t = e
l.y = b
i.y = b
assert i.y.q.y.q.y.q.txt == "l"