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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: B = None
        self.y: C = None
        self.o: C = None
        self.txt = txt

b = A("b")
c = B("c")
d = C("d")
n = D("n")
g = E("g")
m = F("m")
h = C("h")

b.s = c
b.t = m
c.p = b
c.q = g
c.r = d
d.y = h
d.x = m
d.z = b
n.o = m
g.s = m
m.z = c
m.u = c
m.y = h
m.o = d
h.y = d
h.x = m
h.z = b
assert b.s.q.s.o.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: F = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: B = None
        self.y: C = None
        self.o: C = None
        self.txt = txt

b = A("b")
c = B("c")
d = C("d")
n = D("n")
g = E("g")
m = F("m")
h = C("h")

b.s = c
b.t = m
c.p = b
c.q = g
c.r = d
d.y = h
d.x = m
d.z = b
n.o = m
g.s = m
m.z = c
m.u = c
m.y = h
m.o = d
h.y = d
h.x = m
h.z = b
assert b.s.q.s.o.z.t.txt == "m"