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

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

class C:
    def __init__(self, txt: str):
        self.x: F = None
        self.t: D = None
        self.v: E = None
        self.u: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: E = None
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: D = None
        self.txt = txt

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

b = A("b")
g = B("g")
m = C("m")
j = D("j")
h = E("h")
f = F("f")

b.p = h
b.q = g
g.q = j
m.x = f
m.t = j
m.v = h
m.u = h
j.z = g
j.x = h
j.o = h
h.v = g
h.r = j
f.x = j
assert f.x.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: F = None
        self.t: D = None
        self.v: E = None
        self.u: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: E = None
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: D = None
        self.txt = txt

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

b = A("b")
g = B("g")
m = C("m")
j = D("j")
h = E("h")
f = F("f")

b.p = h
b.q = g
g.q = j
m.x = f
m.t = j
m.v = h
m.u = h
j.z = g
j.x = h
j.o = h
h.v = g
h.r = j
f.x = j
assert f.x.z.q.txt == "j"