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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = None
        self.p: A = None
        self.txt = txt

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

d = A("d")
h = B("h")
j = C("j")
m = D("m")
l = E("l")
b = F("b")

d.w = m
d.q = h
h.r = b
h.w = j
j.s = l
j.q = l
j.w = h
j.o = d
m.s = h
l.z = j
l.x = j
l.p = d
b.x = d
b.t = h
assert b.t.r.x.q.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = None
        self.p: A = None
        self.txt = txt

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

d = A("d")
h = B("h")
j = C("j")
m = D("m")
l = E("l")
b = F("b")

d.w = m
d.q = h
h.r = b
h.w = j
j.s = l
j.q = l
j.w = h
j.o = d
m.s = h
l.z = j
l.x = j
l.p = d
b.x = d
b.t = h
assert b.t.r.x.q.w.w.txt == "h"