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

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: A = None
        self.txt = txt

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

l = A("l")
d = B("d")
b = C("b")
a = A("a")
h = C("h")
j = B("j")

l.y = a
l.z = b
l.o = h
d.w = b
d.x = l
b.w = h
a.y = l
a.z = h
a.o = h
h.w = b
j.w = b
j.x = l
assert j.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.z: C = None
        self.o: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: A = None
        self.txt = txt

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

l = A("l")
d = B("d")
b = C("b")
a = A("a")
h = C("h")
j = B("j")

l.y = a
l.z = b
l.o = h
d.w = b
d.x = l
b.w = h
a.y = l
a.z = h
a.o = h
h.w = b
j.w = b
j.x = l
assert j.w.w.w.w.w.w.txt == "h"