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

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

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: E = None
        self.txt = txt

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

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

j = A("j")
f = B("f")
h = C("h")
a = D("a")
c = E("c")
l = F("l")

j.o = a
f.s = j
h.r = l
a.t = h
a.z = c
c.t = h
c.w = j
l.p = h
assert f.s.o.t.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: E = None
        self.txt = txt

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

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

j = A("j")
f = B("f")
h = C("h")
a = D("a")
c = E("c")
l = F("l")

j.o = a
f.s = j
h.r = l
a.t = h
a.z = c
c.t = h
c.w = j
l.p = h
assert f.s.o.t.r.p.txt == "h"