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

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

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

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

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

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

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

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

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

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

g.p = f
g.o = f
g.y = l
g.s = a
c.q = g
c.x = k
b.x = m
b.t = c
b.s = g
k.q = f
a.p = k
a.o = k
a.y = l
a.s = g
m.x = b
m.t = l
m.s = g
l.q = a
l.x = k
f.q = k
assert f.q.q.q.q.q.q.txt == "f"