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

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

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

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

b = A("b")
l = B("l")
h = C("h")
d = D("d")
j = B("j")
f = D("f")
g = A("g")

b.o = g
b.p = g
l.y = j
h.s = l
h.p = l
h.q = f
h.y = j
d.v = f
d.y = g
d.t = h
j.y = l
f.v = d
f.y = b
f.t = h
g.o = b
g.p = b
assert j.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.p: A = None
        self.txt = txt

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

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

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

b = A("b")
l = B("l")
h = C("h")
d = D("d")
j = B("j")
f = D("f")
g = A("g")

b.o = g
b.p = g
l.y = j
h.s = l
h.p = l
h.q = f
h.y = j
d.v = f
d.y = g
d.t = h
j.y = l
f.v = d
f.y = b
f.t = h
g.o = b
g.p = b
assert j.y.y.y.y.y.y.y.txt == "l"