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

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: C = None
        self.txt = txt

i = A("i")
m = B("m")
c = C("c")
j = D("j")
k = B("k")
h = B("h")
l = A("l")

i.r = k
m.y = l
c.o = i
j.u = l
j.r = c
k.y = l
h.y = i
l.r = h
assert k.y.r.y.r.y.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: C = None
        self.txt = txt

i = A("i")
m = B("m")
c = C("c")
j = D("j")
k = B("k")
h = B("h")
l = A("l")

i.r = k
m.y = l
c.o = i
j.u = l
j.r = c
k.y = l
h.y = i
l.r = h
assert k.y.r.y.r.y.r.y.txt == "i"