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

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: D = None
        self.p: B = None
        self.txt = txt

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

c = A("c")
h = B("h")
k = C("k")
f = D("f")
l = A("l")
g = B("g")
b = D("b")

c.o = f
c.y = l
h.p = b
k.r = g
k.s = b
k.p = h
f.t = b
f.o = b
l.o = b
l.y = c
g.p = f
b.t = f
b.o = f
assert l.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.y: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: D = None
        self.p: B = None
        self.txt = txt

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

c = A("c")
h = B("h")
k = C("k")
f = D("f")
l = A("l")
g = B("g")
b = D("b")

c.o = f
c.y = l
h.p = b
k.r = g
k.s = b
k.p = h
f.t = b
f.o = b
l.o = b
l.y = c
g.p = f
b.t = f
b.o = f
assert l.y.y.y.y.txt == "l"