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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: F = None
        self.txt = txt

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

d = A("d")
a = B("a")
i = C("i")
b = D("b")
f = E("f")
h = F("h")

d.x = i
d.r = i
d.o = i
d.s = a
d.w = a
a.s = h
a.x = b
a.q = i
i.r = h
i.q = a
i.o = b
b.z = i
f.r = d
f.p = h
h.y = f
assert f.r.s.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.s: B = None
        self.w: B = None
        self.r: C = None
        self.o: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: F = None
        self.txt = txt

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

d = A("d")
a = B("a")
i = C("i")
b = D("b")
f = E("f")
h = F("h")

d.x = i
d.r = i
d.o = i
d.s = a
d.w = a
a.s = h
a.x = b
a.q = i
i.r = h
i.q = a
i.o = b
b.z = i
f.r = d
f.p = h
h.y = f
assert f.r.s.q.o.txt == "b"