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

class B:
    def __init__(self, txt: str):
        self.v: G = None
        self.p: D = None
        self.s: A = None
        self.o: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.v: B = None
        self.y: D = None
        self.txt = txt

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

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

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

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

c = A("c")
d = B("d")
f = C("f")
l = D("l")
b = E("b")
m = F("m")
n = G("n")

c.o = l
d.v = n
d.p = l
d.s = c
d.o = b
f.x = d
f.v = d
f.y = l
l.r = b
b.o = f
b.w = f
b.r = c
b.q = c
b.v = d
m.o = n
m.q = b
m.r = c
m.p = f
n.t = c
n.v = f
assert b.q.o.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: G = None
        self.p: D = None
        self.s: A = None
        self.o: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.v: B = None
        self.y: D = None
        self.txt = txt

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

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

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

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

c = A("c")
d = B("d")
f = C("f")
l = D("l")
b = E("b")
m = F("m")
n = G("n")

c.o = l
d.v = n
d.p = l
d.s = c
d.o = b
f.x = d
f.v = d
f.y = l
l.r = b
b.o = f
b.w = f
b.r = c
b.q = c
b.v = d
m.o = n
m.q = b
m.r = c
m.p = f
n.t = c
n.v = f
assert b.q.o.r.v.txt == "d"