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

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

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

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

f = A("f")
h = B("h")
k = C("k")
g = D("g")
a = D("a")
b = A("b")
e = B("e")

f.r = e
f.t = k
f.x = k
h.o = b
h.y = a
h.t = k
h.s = g
k.p = f
k.q = e
g.q = h
g.t = f
a.q = e
a.t = b
b.r = e
b.t = k
b.x = k
e.o = b
e.y = g
e.s = g
e.t = k
assert b.r.s.t.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: C = None
        self.x: C = None
        self.txt = txt

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

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

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

f = A("f")
h = B("h")
k = C("k")
g = D("g")
a = D("a")
b = A("b")
e = B("e")

f.r = e
f.t = k
f.x = k
h.o = b
h.y = a
h.t = k
h.s = g
k.p = f
k.q = e
g.q = h
g.t = f
a.q = e
a.t = b
b.r = e
b.t = k
b.x = k
e.o = b
e.y = g
e.s = g
e.t = k
assert b.r.s.t.t.q.txt == "e"